home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-02
/
tsptp.zip
/
SAVAGE.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1993-04-09
|
2KB
|
77 lines
(******************************************************************************)
(* SAVAGE.PAS *)
(* Derived from the BYTE listings. Floating point speed and accuracy test. *)
(* A BASIC version appeared in Dr. Dobb's Journal, Sep. 1983, pp. 120-122. *)
(******************************************************************************)
PROGRAM SAVAGE(Output);
(******************************************************************************)
(* TIMING *)
(******************************************************************************)
(*$IFNDEF TopSpeed *)
(*%F TRUE *** Compile for Turbo Pascal ***)
USES TPBench;
(*%E*)
(*$ELSE *** Compile for TopSpeed Pascal ***)
IMPORT TSBench *;
(*$ENDIF *)
(******************************************************************************)
VAR
A : BmReal;
FUNCTION Tan(x : BmReal): BmReal;
(* Note no range checking is performed. *)
BEGIN
Tan := sin(x) / cos(x);
END;
PROCEDURE SavageProc;
VAR I : BmInt;
BEGIN
A := 1.0;
FOR I := 1 TO 2500 DO
A := Tan(arctan(exp(ln(sqrt(A * A))))) + 1.0;
END;
BEGIN
WriteLn('Savage Benchmark');
(******************************************************************************)
(* Compute the looping overhead. The Dummy procedure must have some side- *)
(* effect so that it is not optimised out of existence. *)
(******************************************************************************)
StartTimer; (* Start the clock. *)
REPEAT
Dummy;
UNTIL NullTimesUp;
(******************************************************************************)
(* Now run the benchmark. Note that the Dummy procedure is also called so *)
(* that we can eliminate its overhead from the looping overhead. *)
(******************************************************************************)
StartTimer; (* Start the clock. *)
REPEAT
SavageProc;
Dummy
UNTIL BenchTimesUp;
(******************************************************************************)
ReportTimes;
WriteLn;
WriteLn('Result: A = ', A:10);
END.